/**
 * @(#)Lenguaje.java 4/06/2010
 *
 * Copyright (c) 2007-2012 PsiqueWare S.A. de C.V. All Rights Reserved.
 * This software is the proprietary information PsiqueWare S.A. de C.V.
 * Use is subject to license terms.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 * <br/>Usuario : AngelElectrico
 * <br/>Creaci&oacute;n: 4/06/2010 - 11:25:59 AM
 * <br/>
 * <br/>
 * <br/><t5>Cambios :</t5>
 * <br/><b>Fecha | Autor  |  Cambios</b>
 * <ul>
 * <li>4/06/2010 | <a href = "mailto:AngelElectrico@PsiqueWare.com">&Aacute;ngel El&eacute;ctrico</a> | Creaci&oacute;n del Objeto.</li>
 *
 * </ul>
 */

package com.psiqueware.alheli.i18n;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

/**
 * Lenguaje a utilizar en la aplicaci&oacute;n.
 * <br/>Paquete Original: com.psiqueware.orquidea.diccionario.traductor
 * <br/>Nombre  Original: Lenguaje
 * <br/>Oprima para ver : <a href="Lenguaje.java.html"><i>C&oacute;digo Fuente</i> </a>
 *
 * @author <a href="mailto:AngelElectrico@PsiqueWare.com">AngelElectrico</a>
 * @version Revision: 1.1 4/06/2010 11:25:59 AM
 * @noinspection StaticVariableOfConcreteClass, StaticVariableNamingConvention, ClassWithoutNoArgConstructor, ClassWithoutLogger, ValueOfIncrementOrDecrementUsed, NonFinalStaticVariableUsedInClassInitialization, MethodReturnOfConcreteClass, UnusedDeclaration
 */
public enum Lenguaje
{

    AFRIKAANS(1L, "Afrikaans", "Afrikaans", "af", false),
    ALBANIAN(2L, "Albanian", "Shqip", "sq", false),
    AMHARIC(3L, "Amharic", "\u12a0\u121b\u122d\u129b", "am", false),
    ARABIC(4L, "Arabic", "\u0627\u0644\u0639\u0631\u0628\u064a\u0629", "ar", true),
    ARMENIAN(5L, "Armenian", "\u0540\u0561\u0575\u0565\u0580\u0565\u0576", "hy", false),
    AZERBAIJANI(6L, "Azerbaijani", "Az\u0259rbaycan Dili", "az", false),
    BASQUE(7L, "Basque", "Euskara, Euskera", "eu", false),
    BELARUSIAN(8L, "Belarusian", "\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f", "be", false),
    BENGALI(9L, "Bengali", "\u09ac\u09be\u0982\u09b2\u09be", "bn", false),
    BIHARI(10L, "Bihari", "\u092d\u094b\u091c\u092a\u0941\u0930\u0940", "bh", false),
    BULGARIAN(11L, "Bulgarian", "\u0411\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438 \u0415\u0437\u0438\u043a", "bg", true),
    BURMESE(12L, "Burmese", "\u1017\u1019\u102c\u1005\u102c", "my", false),
    CATALAN(13L, "Catalan", "Catal\u00e0", "ca", false),
    CHEROKEE(14L, "Cherokee", "Cherokee", "ch", false),
    CHINESE(15L, "Chinese", "\u4e2d\u6587 (Zh\u014dngw\u00e9n,true,false), \u6c49\u8bed, \u6f22\u8a9e", "zh", false),
    CHINESE_SIMPLIFIED(16L, "Chinese Simplified", "\u4e2d\u6587 (Zh\u014dngw\u00e9n,true,false), \u6c49\u8bed, \u6f22\u8a9e", "zh-CHS", true),
    CHINESE_TRADITIONAL(17L, "Chinese Traditional", "\u4e2d\u6587 (Zh\u014dngw\u00e9n,true,false), \u6c49\u8bed, \u6f22\u8a9e", "zh-CHT", true),
    CROATIAN(18L, "Croatian", "Hrvatski", "hr", false),
    CZECH(19L, "Czech", "\u010cesky, \u010ce\u0161tina", "cs", true),
    DANISH(20L, "Danish", "Dansk", "da", true),
    DHIVEHI(21L, "Dhivehi", "\u078b\u07a8\u0788\u07ac\u0780\u07a8", "dv", false),
    DUTCH(22L, "Dutch", "Nederlands, Vlaams", "nl", true),
    ENGLISH(23L, "English", "English", "en", true),
    ESPERANTO(24L, "Esperanto", "Esperanto", "eo", false),
    ESTONIAN(25L, "Estonian", "Eesti, Eesti Keel", "et", true),
    FILIPINO(26L, "Filipino", "Vosa Vakaviti", "fj", false),
    FINNISH(27L, "Finnish", "Suomi, Suomen Kieli", "fi", true),
    FRENCH(28L, "French", "Fran\u00e7ais, Langue Fran\u00e7aise", "fr", true),
    GALICIAN(29L, "Galician", "Galego", "gl", false),
    GEORGIAN(30L, "Georgian", "\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8", "ka", false),
    GERMAN(31L, "German", "Deutsch", "de", true),
    GREEK(32L, "Greek", "\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac", "el", true),
    GUARANI(33L, "Guarani", "Ava\u00f1e'\u1ebd", "gn", false),
    GUJARATI(34L, "Gujarati", "\u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0", "gu", false),
    HEBREW(35L, "Hebrew", "\u05e2\u05d1\u05e8\u05d9\u05ea", "he", true),
    HINDI(36L, "Hindi", "\u0939\u093f\u0928\u094d\u0926\u0940, \u0939\u093f\u0902\u0926\u0940", "hi", false),
    HUNGARIAN(37L, "Hungarian", "Magyar", "hu", true),
    ICELANDIC(38L, "Icelandic", "\u00cdslenska", "is", false),
    INDONESIAN(39L, "Indonesian", "Bahasa Indonesia", "id", true),
    INUKTITUT(40L, "Inuktitut", "\u00cdslenska", "is", false),
    IRISH(41L, "Irish", "Gaeilge", "ga", false),
    ITALIAN(42L, "Italian", "Italiano", "it", true),
    JAPANESE(43L, "Japanese", "\u65e5\u672c\u8a9e (\u306b\u307b\u3093\u3054\uff0f\u306b\u3063\u307d\u3093\u3054)", "ja", true),
    KANNADA(44L, "Kannada", "\u0c95\u0ca8\u0ccd\u0ca8\u0ca1", "kn", false),
    KAZAKH(45L, "Kazakh", "\u049a\u0430\u0437\u0430\u049b \u0422\u0456\u043b\u0456", "kk", false),
    KHMER(46L, "Khmer", "Kikongo", "kg", false),
    KOREAN(47L, "Korean", "\ud55c\uad6d\uc5b4 (\u97d3\u570b\u8a9e,true,false), \uc870\uc120\ub9d0 (\u671d\u9bae\u8a9e)", "ko", true),
    KURDISH(48L, "Kurdish", "Kurd\u00ee, \u0643\u0648\u0631\u062f\u06cc\u200e", "ku", false),
    KYRGYZ(49L, "Kyrgyz", "\u041a\u044b\u0440\u0433\u044b\u0437 \u0422\u0438\u043b\u0438", "ky", false),
    LAOTHIAN(50L, "Laothian", "Latine, Lingua Latina", "la", false),
    LATVIAN(51L, "Latvian", "Latvie\u0161u Valoda", "lv", true),
    LITHUANIAN(52L, "Lithuanian", "Lietuvi\u0173 Kalba", "lt", true),
    MACEDONIAN(53L, "Macedonian", "\u041c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438 \u0408\u0430\u0437\u0438\u043a", "mk", false),
    MALAY(54L, "Malay", "Bahasa Melayu, \u0628\u0647\u0627\u0633 \u0645\u0644\u0627\u064a\u0648\u200e", "ms", false),
    MALAYALAM(55L, "Malayalam", "\u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02", "ml", false),
    MALTESE(56L, "Maltese", "Malti", "mt", false),
    MARATHI(57L, "Marathi", "Kajin M\u0327Aje\u013c", "mh", false),
    MONGOLIAN(58L, "Mongolian", "\u041c\u043e\u043d\u0433\u043e\u043b", "mn", false),
    NEPALI(59L, "Nepali", "\u0928\u0947\u092a\u093e\u0932\u0940", "ne", false),
    NORWEGIAN(60L, "Norwegian", "Norsk", "no", true),
    ORIYA(61L, "Oriya", "\u0b13\u0b21\u0b3c\u0b3f\u0b06", "or", false),
    PASHTO(62L, "Pashto", "\u067e\u069a\u062a\u0648", "ps", false),
    PERSIAN(63L, "Persian", "\u0641\u0627\u0631\u0633\u06cc", "fa", false),
    POLISH(64L, "Polish", "Polski", "pl", true),
    PORTUGUESE(65L, "Portuguese", "Portugu\u00eas", "pt", true),
    PUNJABI(66L, "Punjabi", "Punjabi", "pj", false),
    ROMANIAN(67L, "Romanian", "Rom\u00e2n\u0103", "ro", true),
    RUSSIAN(68L, "Russian", "\u0420\u0443\u0441\u0441\u043a\u0438\u0439 \u042f\u0437\u044b\u043a", "ru", true),
    SANSKRIT(69L, "Sanskrit", "\u0938\u0902\u0938\u094d\u0915\u0943\u0924\u092e\u094d", "sa", false),
    SERBIAN(70L, "Serbian", "\u0421\u0440\u043f\u0441\u043a\u0438 \u0408\u0435\u0437\u0438\u043a", "sr", false),
    SINDHI(71L, "Sindhi", "\u0938\u093f\u0928\u094d\u0927\u0940, \u0633\u0646\u068c\u064a\u060c \u0633\u0646\u062f\u06be\u06cc\u200e", "sd", false),
    SINHALESE(72L, "Sinhalese", "\u0dc3\u0dd2\u0d82\u0dc4\u0dbd", "si", false),
    SLOVAK(73L, "Slovak", "Sloven\u010dina", "sk", true),
    SLOVENIAN(74L, "Slovenian", "Sloven\u0161\u010dina", "sl", true),
    SPANISH(75L, "Spanish", "Espa\u00f1ol, Castellano", "es", true),
    SWAHILI(76L, "Swahili", "Kiswahili", "sw", false),
    SWEDISH(77L, "Swedish", "Svenska", "sv", true),
    TAGALOG(78L, "Tagalog", "Wikang Tagalog, \u170f\u1712\u1703\u1705\u1714 \u1706\u1704\u170e\u1713\u1704\u1714", "tl", false),
    TAJIK(79L, "Tajik", "\u0422\u043e\u04b7\u0438\u043a\u04e3, To\u011fik\u012b, \u062a\u0627\u062c\u06cc\u06a9\u06cc\u200e", "tg", false),
    TAMIL(80L, "Tamil", "\u0ba4\u0bae\u0bbf\u0bb4\u0bcd", "ta", false),
    TELUGU(81L, "Telugu", "\u0c24\u0c46\u0c32\u0c41\u0c17\u0c41", "te", false),
    THAI(82L, "Thai", "\u0e44\u0e17\u0e22", "th", true),
    TIBETAN(83L, "Tibetan", "\u0f56\u0f7c\u0f51\u0f0b\u0f61\u0f72\u0f42", "bo", false),
    TURKISH(84L, "Turkish", "T\u00fcrk\u00e7e", "tr", true),
    UIGHUR(85L, "Uighur", "Uy\u01a3urq\u0259, \u0626\u06c7\u064a\u063a\u06c7\u0631\u0686\u06d5\u200e", "ug", false),
    UKRANIAN(86L, "Ukranian", "\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430", "uk", true),
    URDU(87L, "Urdu", "\u0627\u0631\u062f\u0648", "ur", false),
    UZBEK(88L, "Uzbek", "O'Zbek, \u040e\u0437\u0431\u0435\u043a, \u0623\u06c7\u0632\u0628\u06d0\u0643\u200e", "uz", false),
    VIETNAMESE(89L, "Vietnamese", "Ti\u1ebfng Vi\u1ec7t", "vi", true),
    WELSH(90L, "Welsh", "Cymraeg", "cy", false),
    YIDDISH(91L, "Yiddish", "\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9", "yi", false),
    HATIAN(92L, "Hatian", "Hatian", "ht", true);


    /**
     * Nombre de este Lenguaje.
     */
    private String m_nombreIngles;

    /**
     * Identificador &uacute;nico de esta Lenguaje.
     * Se utiliza de tipo Long para poder portar esta clase facilmente a un cat&aacute;logo.
     */
    private Long m_id;


    /**
     * Nombre en letras del idioma que represanta.
     */
    private final String m_nombreLocalizado;

    /**
     * Iso del {@link Locale}.
     */
    private final String m_iso;

    /**
     * Bandera que indica el {@link Lenguaje} es soportado por Bing.
     */
    private final boolean m_bing;


    /**
     * Construye un Lenguaje a partir de un nombre y un id.
     * <p>Es una enumeraci&oacute;n por lo tanto el constructor es privado.</p>
     *
     * @param id               identificador unico del Lenguaje.
     * @param nombreIngles     del lenguaje en Ingl&eacute;s.
     * @param nombreLocalizado Nombre en letras del idioma que represanta.
     * @param iso              clave ISO del lenguaje para crear locales.
     * @param bing             Bandera que indica el {@link Lenguaje} es soportado por Bing.
     */
    private Lenguaje(final Long id, final String nombreIngles, final String nombreLocalizado, final String iso, final boolean bing)
    {
        m_nombreIngles = nombreIngles;
        m_id = id;
        m_nombreLocalizado = nombreLocalizado;
        m_iso = iso;
        m_bing = bing;
    }

    /**
     * Convierte este {@link Lenguaje} a su representaci&oacute;n textual.
     *
     * @noinspection DuplicateStringLiteralInspection, HardCodedStringLiteral
     */
    public String toString()
    {
        final StringBuilder sb = new StringBuilder();
        sb.append("<Instance Class = '").append(this.getClass()).append("'>");
        sb.append("<id>").append(m_id).append("</id>");
        sb.append("<nombre>").append(m_nombreIngles).append("</nombre>");
        sb.append("</Instance>");
        return sb.toString();
    }

    /**
     * Devuelve el identificador textual de este Lenguaje.
     *
     * @return String con el nombre.
     */
    public String getNombreIngles()
    {
        return m_nombreIngles;
    }


    /**
     * Devuelve el identificador &uacute;nico de este Lenguaje.
     *
     * @return Long con el id.
     */
    public Long getId()
    {
        return m_id;
    }

    /**
     * Devuelve un {@link List} con los {@link Lenguaje} de esta enumeraci&oacute;n.
     */
    private static List<Lenguaje> m_objects = null;

    /**
     * Devuelve una lista con todos los {@link Lenguaje} de la enumeraci&oacute;n.
     *
     * @return nueva List de {@link Lenguaje}};
     *
     * @noinspection ReturnOfCollectionOrArrayField
     */
    public static List<Lenguaje> listLenguaje()
    {
        if (null == m_objects)
        {
            generaListLenguaje();
        }
        return m_objects;
    }

    /**
     * Genera una lista con todos los {@link Lenguaje} de la enumeraci&oacute;n.
     *
     * @return nueva List de {@link Lenguaje};
     */
    private static synchronized List<Lenguaje> generaListLenguaje()
    {
        if (null == m_objects)
        {
            m_objects = new ArrayList<Lenguaje>();
            Collections.addAll(m_objects, values());
        }
        return m_objects;
    }


    /**
     * Devuelve el Lenguaje al que corresponde este id.
     *
     * @param id del Lenguaje buscado.
     *
     * @return {@link Lenguaje}.
     */
    public static Lenguaje desdeId(Long id)
    {
        Lenguaje salida = null;
        for (Lenguaje obj : listLenguaje())
        {
            if (obj.getId().equals(id))
            {
                salida = obj;
                break;
            }
        }
        return salida;
    }

    /**
     * Devuelve el Lenguaje al que corresponde este nombre.
     *
     * @param nombre del Lenguaje buscado.
     *
     * @return {@link Lenguaje}.
     *
     * @noinspection CallToStringEquals
     */
    public static Lenguaje desdeNombre(String nombre)
    {
        Lenguaje salida = null;
        for (Lenguaje obj : listLenguaje())
        {
            if (obj.getNombreIngles().equals(nombre))
            {
                salida = obj;
                break;
            }
        }
        return salida;
    }

    /**
     * Devuelve el Lenguaje al que corresponde este {@link Locale}.
     *
     * @param locale del Lenguaje buscado.
     *
     * @return {@link Lenguaje}.
     *
     * @noinspection CallToStringEquals
     */
    public static Lenguaje desdeLocale(final Locale locale)
    {
        final String isoLng = locale.getLanguage();
        Lenguaje salida = null;
        for (final Lenguaje obj : listLenguaje())
        {
            if (obj.getIso().equalsIgnoreCase(isoLng))
            {
                salida = obj;
                break;
            }
        }
        return salida;
    }


    /**
     * Devuelve la Bandera que indica el {@link Lenguaje} es soportado por Google.
     *
     * @return valor de 'm_bing'.
     */
    public boolean isBing()
    {
        return m_bing;
    }

    /**
     * Devuelve el Iso del {@link Locale}.
     *
     * @return Iso del {@link Locale}.
     */
    public String getIso()
    {
        return m_iso;
    }

    /**
     * Devuelve el Nombre en letras del idioma que represanta.
     *
     * @return Nombre en letras del idioma que represanta.
     */
    public String getNombreLocalizado()
    {
        return m_nombreLocalizado;
    }
}
